package com.zhiwei.msf.gateway.config;

import com.google.code.kaptcha.Producer;
import com.google.code.kaptcha.util.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Properties;

/**
 * function 验证码配置
 * author zhiwei.yang
 * time 2020-3-16-9:14
 */
@Configuration
public class CaptchaConfig {

    @Bean
    public Config config() {
        Properties properties = new Properties();
        properties.put("kaptcha.border", "yes");
        properties.put("kaptcha.border.color", "105,179,90");
        properties.put("kaptcha.image.width", 250);
        properties.put("kaptcha.image.height", 30);
        properties.put("kaptcha.session.key", "captcha");
        properties.put("kaptcha.textproducer.font.size", 25);
        properties.put("kaptcha.textproducer.font.color", "black");
        properties.put("kaptcha.textproducer.font.names", "宋体,楷体,微软雅黑");
        properties.put("kaptcha.textproducer.char.space", 8);
        properties.put("kaptcha.obscurificator.impl", "com.google.code.kaptcha.impl.WaterRipple");
        return new Config(properties);
    }

    @Bean
    public Producer producer(Config config) {
        return config.getProducerImpl();
    }
}